package com.vincent.javacourse.controller;


import com.vincent.javacourse.entity.Question;
import com.vincent.javacourse.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 题库表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-12-24
 */
@RestController
@RequestMapping("//question")
public class QuestionController {
    @Autowired
    private QuestionService questionService;

    @GetMapping("/list")
    private List<Question> list() {
        return this.questionService.list();
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable("id") Integer id) {
        return this.questionService.removeById(id);
    }

    @GetMapping("/find/{id}")
    public Question find(@PathVariable("id") Integer id) {
        return this.questionService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Question question) {
        return this.questionService.save(question);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Question question) {
        return this.questionService.updateById(question);
    }
}

